The <pre> tag

The HTML <pre> tag is used for pre-formatted text. It keeps the original spaces and line breaks exactly as they are in the code. When you use <pre>, the text appears in a fixed-width font, preserving the formatting and layout just as it looks in the HTML code.

Syntax:

<pre> Content </pre> 

Example: This example explains the use of the <pre> tag in the <p> tag.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>HTML paragraph
    </title>
</head>

<body>
    <pre>
    This paragraph has multiple
    lines. But it is displayed 
    as it is unlike the paragraph 
    tag.
   </pre>

    <pre>
    This     paragraph has multiple
    spaces. But     it is displayed 
    as it is    unlike the paragraph 
         tag.
   </pre>
</body>

</html>

Output:

Use of pre tag in the p tag

HTML Paragraphs

The <p> tag in HTML signifies a paragraph. Enclosed within the opening <p> and closing </p> tags, any content is recognized as a paragraph. As a block-level element, a new paragraph inherently starts on a fresh line, with browsers intuitively adding space before and after a paragraph for enhanced readability.

Syntax:

<p> Content </p>

Similar Reads

Properties of the paragraph Tag

The browser reduces multiple spaces added by users to a single space.If a user adds multiple lines, the browser compresses them into a single line.By default, the display of the paragraph element is set to “block,” meaning each new paragraph is placed on a new line. This behavior can be modified using CSS....

The
tag

The HTML
tag element creates a line break, giving you a new line without starting a new paragraph. Use
when you want to move to the next line without beginning a whole new paragraph....

The


tag

The HTML


tag is used to create a horizontal rule or line, visually separating content on a webpage. Use
when you want to insert a horizontal line to signify a division between sections or elements, providing a clear visual break in the page....

Align attribute

The

tag specifically supports the alignment attribute and allows us to align our paragraphs in left, right, or center alignment....

The

 tag

The HTML

 tag is used for pre-formatted text. It keeps the original spaces and line breaks exactly as they are in the code. When you use 
, the text appears in a fixed-width font, preserving the formatting and layout just as it looks in the HTML code....
													

Browser Support

Google Chrome: 1Edge: 12Firefox: 1Opera: 15Safari: 1...

Contact Us